from flask import Flask
from flask_cors import CORS
from flask_session import Session
from datetime import timedelta
from Blueprint import Load, ChangeSheetName, ChangeFieldName, TableConcat, Upload, Compute, ColumnSeparate, FilterData, ColumnMerge, DelField, DelSheet, GetLoad, ClearLoad, Download, postgresSql, SetType, AddField, ClearCache

import os

app = Flask(__name__)
# app.secret_key = os.urandom(16)
CORS(app, supports_credentials=True)

# 注册蓝图
app.register_blueprint(Upload.bp)
app.register_blueprint(TableConcat.bp)
app.register_blueprint(FilterData.bp)
app.register_blueprint(ColumnMerge.bp)
app.register_blueprint(ColumnSeparate.bp)
app.register_blueprint(Load.bp)
app.register_blueprint(Compute.bp)
app.register_blueprint(ChangeSheetName.bp)
app.register_blueprint(ChangeFieldName.bp)
app.register_blueprint(DelField.bp)
app.register_blueprint(DelSheet.bp)
app.register_blueprint(GetLoad.bp)
app.register_blueprint(ClearLoad.bp)
app.register_blueprint(Download.bp)
app.register_blueprint(postgresSql.bp)
app.register_blueprint(SetType.bp)
app.register_blueprint(AddField.bp)
app.register_blueprint(ClearCache.bp)

app.config['SESSION_TYPE'] = 'filesystem'  # session类型为filesystem
app.config['SESSION_PERMANENT'] = False  # 如果设置为False，则关闭浏览器session就失效。
app.config['SESSION_USE_SIGNER'] = False  # 是否对发送到浏览器上session的cookie值进行加密
# app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(seconds=30)
Session(app)

if __name__ == '__main__':
    app.run(debug=True, host='127.0.0.1', port='5000')